#include "Player.h"

Player::Player()
{
	idle = new Animation("./Content/Images/yoshi.bmp", 64, 64, 1, 8);
	left = NULL;
	right = NULL;
	up = NULL;
	down = NULL;

	health = 100;

	pos.x = 0;
	pos.y = 0;

	speed.x = 1;
	speed.y = 1;

	isActive = true;
	isIdle = true;

	facingDirection = Defines::RIGHT;

}

void Player::OnEvent(SDL_Event* event)
{
}

void Player::OnDraw(SDL_Surface* destinationSurface)
{
	if(isActive && isIdle)
	{
		idle->DrawAnimation(destinationSurface, pos.x, pos.y);
	}
	else if(isActive)
	{
		switch(facingDirection)
		{
			case Defines::UP:
				up->DrawAnimation(destinationSurface, pos.x, pos.y);
				Move(facingDirection);
				break;
			case Defines::DOWN:
				down->DrawAnimation(destinationSurface, pos.x, pos.y);
				Move(facingDirection);
				break;
			case Defines::LEFT:
				left->DrawAnimation(destinationSurface, pos.x, pos.y);
				Move(facingDirection);
				break;
			case Defines::RIGHT:
				right->DrawAnimation(destinationSurface, pos.x, pos.y);
				Move(facingDirection);
				break;
		}
	}
}

void Player::Move(int direction)
{
	switch(direction)
	{
	case Defines::UP:
		pos.y -= speed.y;
		break;
	case Defines::DOWN:
		pos.y += speed.y;
		break;
	case Defines::LEFT:
		pos.x += speed.x;
		break;
	case Defines::RIGHT:
		pos.x -= speed.x;
		break;
	}
}